/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : pop_waiting_app.js
*  Description  : 웨이팅 신청 
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-07-06  김효순    Created.  
*******************************************************************************/

jQuery(function($){
	// 예약정보
	function clsReserveInfo()
	{
		this._HTMLDom = null;
		this.infoData = null;
		
		this._init();
	}
	
	clsReserveInfo.prototype = {
		_init: function(){
			var $layer = $("div.pw_area02");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.setInfo({});
		}
		, setInfo: function(thisData){
			this.infoData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("strong:first").html(_util.nvl(this.infoData["내용"]));
			$layer.find("img[alt='확인']").hide();
			if(this.infoData["예약코드"]) $layer.find("img[alt='확인']").show();
			
			_util.setWindowSize();
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, getReserveInfo: function(){
			return this.infoData["예약정보"];
		}
	}
	
	function clsComm()
	{
		
		
		this._init();
	}
	
	clsComm.prototype = {
		_init: function(){
			
		}
		
	}
	
	
	// 컨트롤
	function clsControl()
	{
		this.objComm = null;
		this.objReserveInfo = null;
		
		this.openerControl = null;
	}
	
	clsControl.prototype = {
		_init: function(){
			this._preload();
			
			this.objComm = new clsComm();
			this.objReserveInfo = new clsReserveInfo();
			
			this._beforeStart();
			this._bind();
			this._start();
		}
		, _preload: function(){
			_gf.spinStart();
			
			if(opener){
				if(opener.document){
					this.openerControl = opener.document.objControl;
				}
			}
			
			if(!this.openerControl){
				self.close();
				return;
			}
		}
		, _beforeStart: function(){
			_gf.spinEnd();
			this._start();
		}
		, _bind: function(){
			var thisClass = this;
			
			// 확인
			this.objReserveInfo.$getLayer().on("click", "img[alt='확인']", function(){
				thisClass.openerControl.closeWaitingApply(self, thisClass.objReserveInfo.getReserveInfo());
				self.close();
			});
			
			// 닫기
			$(document).on("click", "img[alt='취소'],img[alt='close']", function(){
				self.close();
			});
		}
		, _start: function(){
			var waitingInfo = this.openerControl.getWaitingReserveInfo();
			/*var waitingInfo = {
				"예약코드": 301
				, "내용": "2012년 05월 12일(토)<br>SKY72  하늘코스 6시대<br>"
			}*/
			
			this.objReserveInfo.setInfo(waitingInfo);
		}
	}
	
	document.objControl = new clsControl();
	document.objControl._init();
});